package com.hellogood.yaohuo.server.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.hellogood.yaohuo.server.db.DBHelper;
import com.hellogood.yaohuo.shared.entity.YsDetail;

public class YsDetailDAO extends DBHelper {
	Logger log = Logger.getLogger(this.getClass());
	@Override
	public List<?> initializeObject(ResultSet rs) throws SQLException {
		List<YsDetail> ysDetailList = new ArrayList<YsDetail>();
		if (rs != null) {
			while (rs.next()) {
				YsDetail ysDetail = new YsDetail();
				ysDetail.setYsBillNo(rs.getString("ysBillNo"));
				ysDetail.setPluCode(rs.getString("pluCode"));
				ysDetail.setBarCode(rs.getString("barCode"));
				ysDetail.setDepCode(rs.getString("depCode"));
				ysDetail.setDepName(rs.getString("depName"));
				ysDetail.setPluName(rs.getString("pluName"));
				ysDetail.setBra(rs.getString("bra"));
				ysDetail.setColor(rs.getString("color"));
//				ysDetail.setSglCount(rs.getInt("sglCount"));
				ysDetail.setjPrice(rs.getBigDecimal("jPrice"));
				ysDetail.setSize(rs.getString("csize"));
//				ysDetail.setNetPrice(rs.getFloat("netPrice"));
				ysDetail.setPrice(rs.getBigDecimal("price"));
				ysDetail.setCounts(rs.getInt("counts"));
				ysDetail.setCost(rs.getBigDecimal("cost"));
				ysDetail.setNetCost(rs.getBigDecimal("netCost"));
				ysDetail.setTotal(rs.getBigDecimal("total"));
				ysDetail.setTimeMark(rs.getString("timeMark"));
				ysDetail.setRzDate(rs.getString("rzDate"));
				ysDetail.setRemark(rs.getString("remark"));
				ysDetailList.add(ysDetail);
			}
		}
		return ysDetailList;
	}
	
	@SuppressWarnings("unchecked")
	public List<YsDetail> getDetailByBillNo(String billNo){
		List<YsDetail> list = new ArrayList<YsDetail>();
		String sql = "SELECT * FROM ysDetail WHERE ysBillNo = '" +billNo+"'";
		list = (List<YsDetail>) super.query(sql);
		return list;
	}
}
